﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;

namespace FW
{
    public class command
    {
        public string ExecuteCommandSync(object command)
        {
            try
            {
                System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.UseShellExecute = false;
                procStartInfo.CreateNoWindow = true;
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo = procStartInfo;
                proc.Start();
                string result = proc.StandardOutput.ReadToEnd();
                return result;
            }
            catch (Exception ex)
            {
                return "erro";
            }

        }
        //public void ExecuteCommandAsync(string command)
        //{
        //    try
        //    {
        //        Thread objThread = new Thread(new ParameterizedThreadStart(ExecuteCommandSync));
        //        objThread.IsBackground = true;
        //        objThread.Priority = ThreadPriority.AboveNormal;
        //        objThread.Start(command);
        //    }
        //    catch (ThreadStartException objException)
        //    {
        //    }

        //    catch (ThreadAbortException objException)
        //    {
        //    }

        //    catch (Exception objException)
        //    {
        //    }

        //}
    }
}
